package org.kukker.event;

import org.kukker.Util;

import android.content.ContentValues;

public class Event{
	

	/**
	 * The row id of this event in the events table
	 * 
	 * 
	 */
	public int id; //the local id of this data.
	

	/**
	 * The remote id of this event
	 * 
	 * 
	 */
	public int remoteId; 
	
	

	/**
	 * The origin of this event: 
	 * 0 - local
	 * 1 - upcoming.org
	 */
	public int originId; 
	
	/**
	 * The type of this event: 
	 * 1 - event
	 */
	public int typeId;
	
	public String name;
	public String description;
	
	public String startDate;
	public String endDate;
	
	public String startTime;
	public String endTime;
	
	public String venueName;
	public String venueAddress;
	public String venueCity;
	public String venueCountry;
	
	public String url;
	public String latitude;
	public String longitude;
	
	
		
	private boolean isSaved; //a flag to indicate is this data is saved in the local phone
	
	public ContentValues getContentValues(){
		ContentValues cv = new ContentValues();
		
		//cv.put("id",id);
		cv.put("remoteId",remoteId);		
		cv.put("originId", originId);
		
		cv.put("typeId", typeId);
		
		cv.put("name", getStringNotNull(name));
		cv.put("description", getStringNotNull(description));
		
		cv.put("startDate", getStringNotNull(startDate));
		cv.put("endDate", getStringNotNull(endDate));
		
		cv.put("startTime", getStringNotNull(startTime));
		cv.put("endTime", getStringNotNull(endTime));
		
		cv.put("venueName",getStringNotNull(venueName));		
		cv.put("venueAddress", getStringNotNull(venueAddress));
		cv.put("venueCity", getStringNotNull(venueCity));
		cv.put("venueCountry", getStringNotNull(venueCountry));
		
		cv.put("url", getStringNotNull(url));
		cv.put("longitude", getStringNotNull(url));
		cv.put("latitude", getStringNotNull(url));
		
		return cv;			
	}
	
	public Event dataNotNull(){
		name = getStringNotNull(name);
		description = getStringNotNull(description);
		
		startDate = getStringNotNull(startDate);
		endDate = getStringNotNull(endDate);
		
		startTime = getStringNotNull(startTime);
		endTime = getStringNotNull(endTime);
		
		venueName = getStringNotNull(venueName);		
		venueAddress = getStringNotNull(venueAddress);
		venueCity = getStringNotNull(venueCity);
		venueCountry = getStringNotNull(venueCountry);
		
		url = getStringNotNull(url);
		longitude = getStringNotNull(longitude);
		latitude = getStringNotNull(latitude);
		
		return this;
		
	}
	

	
	public String getStringNotNull(String txt){
		return Util.kString.getStringNotNull(txt);
	}
	
	public void setIsSaved(boolean isSaved){
		this.isSaved = isSaved;
	}
	
	public boolean getIsSaved(){
		return this.isSaved;
	}
	
	public Event(){
		
	}
	
	/**
	 * Creates an instance and copy from event.
	 * @param event
	 */
	public Event(Event event){
		this.name = event.name;
		this.description = event.description;
		
		this.startDate = event.startDate;
		this.startTime = event.startTime;
		
		this.endDate = event.endDate;
		this.endTime = event.endTime;
		
		this.latitude = event.latitude;
		this.longitude = event.longitude;
		
		this.venueName = event.venueName;
		this.venueAddress = event.venueAddress;
		this.venueCity = event.venueCity;		
		this.venueCountry = event.venueCountry;

		this.url = event.url;
		
		
		this.id = event.id;
		this.isSaved = event.isSaved;
		this.originId = event.originId;
		this.remoteId = event.remoteId;
		this.typeId = event.typeId;

		
	}
	
	
}